package gui.catalogues.telephones.models;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;

import javax.swing.JComboBox;

import model.TelephoneTypes;
import controller.TelephoneTypesController;


public class TelephoneTypesComboBox extends JComboBox {
		
	public TelephoneTypesComboBox() {
		super();
		
		TelephoneTypesController ttc = new TelephoneTypesController();
		try {
			ttc.loadFromDB();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		ArrayList<TelephoneTypes> al = new ArrayList<TelephoneTypes>(ttc.getElementsList());
//		Iterator alIterator = al.iterator();
//		TelephoneTypes tt = null;
//		while(alIterator.hasNext()) {
//			tt = (TelephoneTypes)alIterator.next();
//			this.addItem(tt);
//		}
		
		this.addItem(new TelephoneTypes(-1, "-Seleccione uno-"));
		
		for(TelephoneTypes tts : al) {
			this.addItem(tts);
		}
	}
}